#!/usr/bin/perl
#cmd.cgi

do '../web-lib.pl';

&init_config();
#%access = get_module_acl();
&ReadParse();

&header($text{'carrycommand'},"","index",0,1);
my (@output,$emod,$i);
`$in{'command'} >temp`;
$j=$?>>8;
if ($j>0){
	`$in{'command'} 2>temp`;
}
open (TP,"temp");
@output=<TP>;
close (TP);
#print "\$output=$output[0]";
print "<form name=cmdform action=cmd.cgi method=post>\n";
print "<table class=mode1><tr><td><font size=2><b>$text{'command'}</b></font></td><td ><input name=command type=text size=50></td><td><input name=carry type=submit class=button1 value=$text{'carryout'}></td></tr>\n";
#print "<tr><td colspan=3><textarea name=carryputout rows=10 cols=100>";
print "<tr><td><font size=2><b>$text{'output'}</b></font></td></tr>";
print "<tr><td colspan=3><div class=main><table class=mode1 border=0 bordercolor=#33ccff cellspacing=0 cellpadding=1 width=100%>\n";
print "<tr class=title1><th align=left>$in{'command'}</th></tr>";
$i=0;
if (!$output[0]){
	print "<tr class=mode1><td>$text{'nooutput'}</td></tr>";
}
else{

	foreach (@output){
		if ($i % 2 eq 0){
			$emod="mode1";
		}
		else {
			$emod="mode2";
		}
		print "<tr class=$emod><td>$_</td></tr>";
		$i++;
	}
}
print "</textarea></td></tr>";
print "</table></div></td></tr></table></form>";
&footer("cmd.cgi",$text{'index'});
